package cn.fotoit.product.system.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Data;
import org.hibernate.annotations.*;

import javax.persistence.*;
import javax.persistence.Entity;
import javax.persistence.Index;
import javax.persistence.Table;
import java.io.Serializable;
import java.util.Date;

/**
 * 员工信息
 */
@Entity
@Table(name = "system_user",indexes = {@Index(columnList = "loginName")})
@Data
public class User implements Serializable {

    //员工id
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Integer id;

    //员工姓名
    @Column(nullable = false)
    private String nickName;


    //登录名
    @Column(length = 50, unique = true, nullable = false)
    private String loginName;

    //登录密码
    @Column(length = 100, nullable = false)
    @JsonIgnore
    private String loginPassword;

    @Column(nullable = false)
    private Integer roleId;

    @CreationTimestamp
    @Column(updatable = false)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date createTime;

    @UpdateTimestamp
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date updateTime;


    //是否锁定 锁定后用户将无法登录
    @ColumnDefault(value = "false")
    private Boolean isLock;


}
